<template>
	<view class="container">
		<mescroll-body    @init="mescrollInit" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback"><yxylCommonLog2 :logList="logs"></yxylCommonLog2>
		<mescroll-empty v-if="logs.length==0"></mescroll-empty>
		</mescroll-body>
	</view>
</template>

<script>
import MescrollBody from 'mescroll-uni/mescroll-body.vue'
import MescrollMixin from "mescroll-uni/mescroll-mixins.js";
import MescrollEmpty from 'mescroll-uni/components/mescroll-empty.vue';
import yxylCommonLog2 from '@/components/yxyl-common-log/yxyl-common-log-2.vue';
export default {
	mixins: [MescrollMixin],
	components: { yxylCommonLog2,MescrollBody,MescrollEmpty },
	data() {
		return {
			logs: [],
			channelId:'',
			downOption: {
				use: true, // 是否启用下拉刷新; 默认true,
				auto: false,
				native:true
			},
			//上拉加载的常用配置
			upOption: {
				use: true, // 是否启用上拉加载; 默认true
				auto: false, // 是否在初始化完毕之后自动执行上拉加载的回调; 默认true
				page: {
					num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
					size: 10 // 每页数据的数量,默认10
				},
				noMoreSize: 2, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
				empty: false,
				textNoMore: '---没有了---'
			}
		};
	},
	onLoad(e) {
		this.channelId = e.ChannelId;
		this.bindList().then(()=>{
			// #ifdef H5
			this.$wechat.hideMenu();
			// #endif
		});
	},
	methods:{
		async bindList(){
			var result=await this.$http.request({
				url:'api/ChannelApi/GetChannelOrderList',
				data:{
					ChannelId: this.channelId,
					Skip:this.logs.length,
					MaxResultCount:30
				}
			});	
			var tempList=new Array();
			for(let index in result)
			{
				tempList.push({title:`时间:${result[index].creationTimeStr}`,text1:`内容:${result[index].goodsName}`,text2:`分成金额:${result[index].orderPrice}`,text3:`用户昵称:${result[index].userName}`});
			}
			this.logs = this.logs.concat(tempList);
			return tempList.length;
		},
		downCallback() {
			this.logs = [];		
			this.bindList()
				.then(() => {
					this.mescroll.endSuccess();
				})
				.catch(() => {
					this.mescroll.endErr();
				});
		},
		async upCallback(page) {
			try {
				var Count = await this.bindList();
				this.mescroll.endSuccess(Count, Count > 0);
			} catch (e) {
				// 失败隐藏下拉加载状态
				this.mescroll.endErr();
			}
		}
	}
};
</script>

<style lang="scss" scoped>
	.container{}
</style>
